/*
** convert_to_decimal.c for my in /home/le_e//project/project_b2/rtv1/lib
** 
** Made by canh-kiet le
** Login   <le_e@epitech.net>
** 
** Started on  Fri Mar  9 17:58:00 2012 canh-kiet le
** Last update Mon Apr 30 21:00:35 2012 canh-kiet le
*/

#include	"my.h"

static int     	define_num(char c)
{
  char		cmp;

  cmp = 'A';
  while (cmp <= 'F')
    {
      if (c == cmp)
	return (cmp - ('A' - 10));
      cmp++;
    }
  if (c >= '0' && c <= '9')
    return (c - '0');
  else
    return (0);
}

int		convert_color(char *s)
{
  int		i;
  int		exp;
  int		res;
  int		base;

  i = 0;
  res = 0;
  base = 16;
  exp = my_strlen(s) - 1;
  if (s == NULL)
    print_err("[Error]: number does not exist.\n");
  while (exp >= 0)
    res += define_num(s[i++]) * pow(base, exp--);
  return (res);
}
